package com.gjp.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * Created by 郭金鹏 on 2018/1/27.
 */
@Service
public class HelloService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "helloFallback")
    public String helloService(String name){
        return restTemplate.getForEntity("http://service-hi/hi?name="+name,String.class).getBody();
    }

    public String helloFallback(String name){
        return name+"：请求错误";
    }
}
